package com.ass.tts.tts.factory;

import com.ass.tts.constant.TTSEnum;
import com.ass.tts.tts.TTSAbstract;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class TTSFactory {


    private final Map<TTSEnum, TTSAbstract> llmMap = new HashMap<>();


    @Autowired
    public TTSFactory(List<TTSAbstract> tts) {
        for (TTSAbstract item : tts) {
            llmMap.put(item.getTTs(), item);
        }
    }

    public TTSAbstract getTTSEnum(TTSEnum ttsEnum) {
        return llmMap.get(ttsEnum);
    }

    /**
     * @describe：小写获得LLM
     * @author：李勇
     * @date：2025/6/22
     * @param lowercase
     * @return：com.sx.llm.chat.LLMChatAbstract
     */
    public TTSAbstract getTTSByLower(String lowercase) {
        TTSEnum ttsEnum = TTSEnum.getLLMEnumByLower(lowercase);
        if (ttsEnum == null) {
            throw new IllegalArgumentException("Invalid code: " + lowercase);
        }
        return getTTSEnum(ttsEnum);
    }

    /**
     * @describe：大写获得LLM
     * @author：李勇
     * @date：2025/6/22
     * @param uppercase
     * @return：com.sx.llm.chat.LLMChatAbstract
     */
    public TTSAbstract getTTSByUpper(String uppercase) {
        TTSEnum ttsEnum = TTSEnum.getLLMEnumByUpper(uppercase);
        if (ttsEnum == null) {
            throw new IllegalArgumentException("Invalid code: " + uppercase);
        }
        return getTTSEnum(ttsEnum);
    }


}
